package org.cybergarage.http;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.cybergarage.util.Debug;
import org.geed.util.UPnPCipher;

public class SecureHTTPRequest extends HTTPRequest {

	public boolean secureSet(InputStream in){
		try{			
			byte[] read = new byte[2048];
			int bytes_read;
			String dataStr = null;
			
			bytes_read = in.read(read);
			dataStr = new String (read, 0, bytes_read);
			
			//decrypt
			if(!UPnPCipher.isCentralize()){
				Debug.message("UPnP Security error");
				return false;
			}
			
			String decStr = "test";//UPnPCipher.decode(dataStr);
			
			ByteArrayInputStream binputStream = new ByteArrayInputStream(decStr.getBytes());
			
			return super.set((InputStream)binputStream,false);
		}catch(Exception e){
			e.printStackTrace();
			
		}
		
		return false;
	}
	
	public boolean read(){
		super.init();
		InputStream in = getSocket().getInputStream();
		
		//return secureSet(in);
		return super.set(in);
	}
	
	
}
